<?php
/************************FoxPHP威客系统************************/
/*                                                            */
/*  FoxPHP.Com (C)2006-2016 FoxPHP Inc.                       */
/*  This is NOT a freeware, use is subject to license terms   */
/*  FoxPHP威客系统是商业软件,使用于商业用途请购买授权         */
/*  V3.0 2016.3                                               */
/*  foxphp@aliyun.com                                         */
/*  http://www.foxphp.com                                     */
/*                                                            */
/**************************************************************/

namespace Admin\Model;
use Think\Model;

class ArticleModel extends AdminModel {
	
	//数据过滤-----------------------------------------------------------------------------------------------
	function FormatData($type=0){
		
		$data['type']=$type;  // 1新闻 2帮助 3案例
		$data['id']=I('get.id',0,'int');
		$data['uid']=$this->uid;
		$data['author']=I('post.author');
		$data['catid']=I('post.catid',0,'int');
		$data['subject']=I('post.subject');
		$data['content']=I('post.content');
		$data['keywords']=I('post.keywords');
		$data['description']=I('post.description');
		$data['show_number']=I('post.show_number',0,'int');
		$data['dateline']=@time();
		$data['status']=I('post.status',0,'int');
		$data['SecurityForm']=I('post.SecurityForm');
		
		if($data['catid']){
			$catid=$data['catid'];
			$categoryarr=M('Category')->token(false)->where("catid=$catid")->find();
			if(!empty($categoryarr['name'])){
				$data['catid_1']=$categoryarr['catid'];
				$data['category_name_1']=$categoryarr['name'];
			}
			
			if($categoryarr['upid']){
				$catid=$categoryarr['upid'];
				$categoryarr=M('Category')->token(false)->where("catid=$catid")->find();
			
				if($categoryarr['name']){
					$data['catid_2']=$categoryarr['catid'];
					$data['category_name_2']=$categoryarr['name'];
				}
				
				if($categoryarr['upid']){
					$catid=$categoryarr['upid'];
					$categoryarr=M('Category')->token(false)->where("catid=$catid")->find();
				
					if($categoryarr['name']){
						$data['catid_1']=$categoryarr['catid'];
						$data['category_name_3']=$categoryarr['name'];
					}
				}
			}
		}
		
		return $data;
	}
	
}

?>